package com.itheima.tlias84.controller;

import com.itheima.tlias84.po.SelectLogmsgPageParam;
import com.itheima.tlias84.service.ReportService;
import com.itheima.tlias84.utils.ResultUtil;
import com.itheima.tlias84.vo.JobVO;
import com.itheima.tlias84.vo.PersonVO;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Objects;

@RestController
@RequestMapping
public class ReportController {
    @Resource
    ReportService reportService;
    @GetMapping("/report/empGenderData")
    public ResultUtil getGenderStats(){
        List<PersonVO> genderStats = reportService.getGenderStats();
        return ResultUtil.success(genderStats);
    }
    @GetMapping("/report/empJobData")
    public ResultUtil getJobStats(){
        JobVO jobStats = reportService.getJobStats();
        return ResultUtil.success(jobStats);
    }

    @GetMapping("/log/page")
    public ResultUtil selectLogmsg(SelectLogmsgPageParam param){
        if (Objects.isNull(param.getPage())||Objects.isNull(param.getPageSize())){
            return ResultUtil.fail();
        }
        ResultUtil resultUtil = reportService.selectLogmsg(param);
        return resultUtil;
    }
}
